//package com.example.myapplication;
//
//import android.os.Bundle;
//import android.util.Log;
//
//import androidx.appcompat.app.AppCompatActivity;
//import androidx.recyclerview.widget.GridLayoutManager;
//import androidx.recyclerview.widget.RecyclerView;
//import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
//
//import com.lzy.okgo.OkGo;
//import com.lzy.okgo.callback.StringCallback;
//import com.lzy.okgo.model.Response;
//
//import org.json.JSONArray;
//import org.json.JSONException;
//import org.json.JSONObject;
//
//import java.util.ArrayList;
//
//
//public class MainActivitycbu extends AppCompatActivity {
//
//    private RecyclerView mainrecycleview;
//    private SwipeRefreshLayout mainSwipeRefreshLayout;
//    private SwipeRefreshLayout.OnRefreshListener getData;
//
//    @Override
//    protected void onCreate(Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//        setContentView(R.layout.item_tianqi);
//        mainrecycleview = findViewById(R.id.mainrecycleview);
//        mainSwipeRefreshLayout = findViewById(R.id.mainSwipeRefreshLayout);
//        mainSwipeRefreshLayout.setColorSchemeColors(
//                getColor(R.color.teal_200),
//                getColor(R.color.teal_700),
//                getColor(R.color.black)
//        );
//        mainSwipeRefreshLayout.setOnRefreshListener(this.getData);
//        getData();
//
//        //发送网络请求，请求接口的数据
//        OkGo.<String>get("https://demo.shopwt.com/api/mobile/index.php?w=goods&t=goods_list&keyword=休闲&page=10&curpage=1&keya=3&order=2&key=")
//                .execute(new StringCallback() {
//                    @Override
//                    public void onSuccess(Response<String> response) {
//                        try {
//                            ArrayList<JSONObject> arrayList = new ArrayList<>();
//                            JSONObject jsonObject = new JSONObject(response.body());
//                            jsonObject = jsonObject.getJSONObject("datas");
//                            JSONArray jsonArray = jsonObject.getJSONArray("goods_list");
//                            for (int i = 0; i < jsonArray.length(); i++) {
//                                arrayList.add(jsonArray.getJSONObject(i));
//                            }
//                            Log.d("TAGS", arrayList.get(0).toString());
//                            GoodsListVerAdapter adapter = new GoodsListVerAdapter(arrayList);
//                            //RecyclerView的简单设置
//                            //LinearLayoutManager linearLayoutManager = new LinearLayoutManager(MainActivity.this);
//                            //linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
//                            GridLayoutManager gridLayoutManager = new GridLayoutManager(MainActivitycbu.this, 2);
//                            mainrecycleview.setLayoutManager(gridLayoutManager);
//                            //将适配器与RecyclerView绑定
//                            mainrecycleview.setAdapter(adapter);
//                            mainSwipeRefreshLayout.setRefreshing(false);
//                        } catch (JSONException e) {
//                            e.printStackTrace();
//                        }
//                    }
//                });
//    }
//
//    private void getData() {
//        OkGo.<String>get("https://demo.shopwt.com/api/mobile/index.php?w=goods&t=goods_list&keyword=休闲&page=10&curpage=1&keya=3&order=2&key=")
//                ArrayList<JSONObject> arrayList = new ArrayList<>();
//        Response<Object> response;
//        JSONObject jsonObject = new JSONObject(response.body());
//                jsonObject = jsonObject.getJSONObject("datas");
//                JSONArray jsonArray = jsonObject.getJSONArray("goods_list");
//                for (int i = 0; i < jsonArray.length(); i++) {
//                    arrayList.add(jsonArray.getJSONObject(i));
//                }
//                Log.d("TAGS", arrayList.get(0).toString());
//                GoodsListVerAdapter adapter = new GoodsListVerAdapter(arrayList);
//                //RecyclerView的简单设置
//                //LinearLayoutManager linearLayoutManager = new LinearLayoutManager(MainActivity.this);
//                //linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
//                GridLayoutManager gridLayoutManager = new GridLayoutManager(MainActivitycbu.this, 2);
//                mainrecycleview.setLayoutManager(gridLayoutManager);
//                //将适配器与RecyclerView绑定
//                mainrecycleview.setAdapter(adapter);
//                mainSwipeRefreshLayout.setRefreshing(false);
//            }  catch (JSONException e) {
//                e.printStackTrace();
//            }
//        }
//        }
//    }
//}
//
//
